using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace TestWindowsClient.Controls
{
	public partial class LoginForm : UserControl
	{
		public LoginForm()
		{
			InitializeComponent();
			this.Load += new EventHandler(LoginForm_Load);
		}
		private bool _result = false;

		public bool Result
		{
			get { return _result; }
		}

		void LoginForm_Load(object sender, EventArgs e)
		{
			if (this.ParentForm != null)
			{
				this.ParentForm.AcceptButton = this.cmdOK;
				this.ParentForm.CancelButton = this.cmdCancel;
			}
		}

		private void cmdOK_Click(object sender, EventArgs e)
		{
			System.Web.Security.MembershipProvider prov = System.Web.Security.Membership.Provider;
			_result = System.Web.Security.Membership.Provider.ValidateUser(txtUsername.Text, txtPassword.Text);
			if (!_result)
			{
				this.ParentForm.DialogResult = DialogResult.None;
				MessageBox.Show("Your username and/or password is invalid.");
			}
		}
	}
}
